Skip to content

Conversation

@pmenzel
Copy link
Contributor

@pmenzel pmenzel commented Aug 4, 2026

Enable LTO and Rust support.

pmenzel and others added 5 commits July 20, 2026 16:41
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
With NPROC ~= 205 on the 256-core build nodes the final links of the
per-language compilers run concurrently and thrash memory (see the
overcommit note at the top of the script). --enable-link-serialization=1
serializes those large link steps while leaving compilation parallel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Builds the stage2/stage3 compiler binaries with LTO on top of the
default 3-stage bootstrap, yielding a faster installed gcc at the cost
of longer build time. Worth it for a compiler installed once and used
institute-wide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds rust to --enable-languages. Note gccrs is experimental and its
build requires rustc and cargo present on the build host; if those are
missing (or too old) the build will fail and this commit can be
reverted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bootstrap-lto fails the stage2/stage3 bootstrap comparison:

    Comparing stages 2 and 3
    Bootstrap comparison failure!
    gcc/rust/rust-desugar-apit.o differs
    gcc/tree-ssa-sccvn.o differs
    make[2]: *** [Makefile:29036: compare] Error 1
    make[2]: Leaving directory '/pkg/gcc-16.1.0-0/build/gcc-16.1.0/objdir'
    make[1]: *** [Makefile:29016: stage3-bubble] Error 2
    make[1]: Leaving directory '/pkg/gcc-16.1.0-0/build/gcc-16.1.0/objdir'
    make: *** [Makefile:1140: all] Error 2

Full log: /scratch/tmp/gcc-16.1.0-0.build.log

The Rust front end is not at fault -- tree-ssa-sccvn.o is core middle
end. Analysis of the two objects left behind in objdir shows the
mismatch is confined to data that only exists in slim LTO objects. Both
have an identical list of 439 sections and all per-function GIMPLE body
streams are byte identical; only the IPA summary streams differ:

    section                stage2    stage3
    .gnu.lto_.jmpfuncs     0x4018    0x401d
    .gnu.lto_.ipa_modref   0x1bdb    0x1bcb
    .gnu.lto_.decls        0x4a59a   0x4a76b
    .gnu.lto_.opts         0xe7      0xe6

The .opts difference is a red herring. objdir/Makefile:620,622 builds
stage2 with -fno-checking and stage3 with -fchecking=1 to avoid
redundant IL verification, and that flag is recorded in .gnu.lto_.opts,
which is why bootstrap-lto uses contrib/compare-lto (it strips that
section) rather than cmp. Recompiling gcc/tree-ssa-sccvn.cc twice with
the same stage2 compiler, varying only that flag, yields objects that
differ solely in .gnu.lto_.opts, and compare-lto passes. So the summary
stream difference is real, not a comparison artefact.

Code generation itself agrees. Compiling the same file with the stage1
and the stage2 compiler without -flto gives byte identical .text,
.rodata and .data. The stage1 and stage2 compilers thus emit the same
machine code and the same GIMPLE, and disagree only on IPA jump
function and modref summaries -- layout sensitive ordering exposed
because the stage2 compiler is itself LTO and IPA optimised while
stage1 is not. A plain bootstrap would compare clean; the failure is an
artefact of LTO-compiling stage2.

bootstrap-lto-lean avoids this. config/bootstrap-lto-lean.mk adds
-flto=jobserver to STAGE3_CFLAGS only, so stage1 and stage2 stay
non-LTO, and it sets do-compare = /bin/true because plain stage2
objects can never compare equal to slim LTO stage3 objects anyway. The
STAGEtrain_*/STAGEfeedback_* lines in that file apply to
profiledbootstrap only and are inert here.

Since all depends on stage3-bubble, stage3 is the final stage and is
what make install installs, so the installed compiler is still LTO
optimised -- the full benefit of commit 24b4ffd is kept, at one
LTO pass instead of two. What is given up is the stage2/stage3 self
check, which bootstrap-lto could not deliver here in any case; make
check remains the validation. Neither config LTO-optimises the target
libraries, as both touch only *_CFLAGS and not *_TFLAGS.

The underlying nondeterminism in IPA summary streaming under an LTO
bootstrap looks worth reporting upstream.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant